import apiType, {
    GET_ALL_PROMOTION_WITH_STATS,
    GET_ALL_COUPONS,
    GET_COUPONS_DISTRIBUTION_STATS,
    GET_PROMOTION
} from "@constants/ActionTypes";

const initialState = {
    promotionStats: {}, // 促销活动统计
    allCoupons: {}, // 优惠券
    allPromotion: {}, // 促销活动
    couponDistributionStats: {}, // 优惠券投放和统计
}

export default function update(state = initialState, action) {
    const { response, params, payload } = action
    switch (action.type) {
        case apiType(GET_ALL_PROMOTION_WITH_STATS).success:
            return {
                ...state,
                promotionStats: response,
            }
        case apiType(GET_ALL_COUPONS).success:
            return {
                ...state,
                allCoupons: response,
            }
        case apiType(GET_PROMOTION).success:
            return {
                ...state,
                allPromotion: response,
            }
        case apiType(GET_COUPONS_DISTRIBUTION_STATS).success:
            return {
                ...state,
                couponDistributionStats: response,
            }
        default:
            return state
    }
}